import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import UnoCSS from 'unocss/vite'
import AutoImport from 'unplugin-auto-import/vite'
import Components from 'unplugin-vue-components/vite'
import { AntDesignVueResolver } from 'unplugin-vue-components/resolvers';
import PxToRem from './px-to-rem';
import path from 'path';
import vueJsx from '@vitejs/plugin-vue-jsx'
import { ElementPlusResolver } from 'unplugin-vue-components/resolvers'

// https://vite.dev/config/
export default defineConfig({
  plugins: [
    PxToRem(),
    vue(),
    UnoCSS(),
    vueJsx(),
    AutoImport({
      dts: 'src/types/auto-imports.d.ts', // 生成类型声明文件，自动引入相关插件
      imports: ['vue', 'pinia', '@vueuse/core', 'vue-router'], // 自动引入哪些内容
      dirs: ['src/composables'], // 自动导入composables目录下的模块
      resolvers: [ElementPlusResolver()],
    }),
    Components({
      dirs: ['src/components'], //自动导入components目录下的组件
      dts: './src/types/components.d.ts', //生成类型声明文件，自动引入相关组件
      resolvers: [
        AntDesignVueResolver({
          importStyle: false,
          resolveIcons: true
        }),
        ElementPlusResolver()
      ],
    }),

  ],
  resolve: {
    alias: {
      '@': path.resolve(__dirname, './src'), // 使用 @ 指向 src 目录
    },
  },
  server:{
    port:7421
  }
})
